/**
 * 用户
 * 加载视频预约的问诊
 */
var uid, name, avatar, ws, cur_date;
document.addEventListener('plusready',function(){ 
	ws = plus.webview.currentWebview();
	uid = plus.storage.getItem('uid'); 
	//获取当前年月日
	var a = new Date();
	var y = a.getFullYear();
	var m = a.getMonth()+1;
	var d = a.getDate();
	if(m < 10)m = '0'+m;
	if(d < 10)d = '0'+d;
	cur_date = y+""+m+""+d; 
	showWating();
	console.log(apiRoot+"?m=home&c=chat&a=yuyue&uid="+uid);
	$.ajax({
		type:"get",
		url:apiRoot+"?m=home&c=chat&a=yuyue&uid="+uid,
		dataType :'json',
		success :function(data){
			plus.nativeUI.closeWaiting(); 
			var str1 = '';
			var over = '';
			$.each(data, function(k, v) { 
				var timeslot = v.timeslot.replace(/-/g,'');//就诊时间替换成数字格式
				if(parseInt(cur_date) <= parseInt(timeslot)){
					str1 += '<ul class="mui-table-view" aid="'+v.aid+'">'+
						'<li class="mui-table-view-cell mui-media">'+
							'<a href="javascript:;">'+
								'<img class="mui-media-object mui-pull-left" src="'+getAvatar(v.mem.avatar)+'">'+
								'<div class="mui-media-body">'+
									v.mem.title+
									'<p class="mui-ellipsis">'+v.addtime+'</p>'+
								'</div>'+
							'</a>'+
							'<span class="span-tx neike">'+v.offices+'</span>'+
						'</li>'+
					'</ul>';
				}else{
					over += v.aid+',';
				}
			});
			$('#content').html(str1);
			if(over != ''){		//修改状态
				$.ajax({type:"get",url:apiRoot+"/home/chat/overBook",data:{id :over}}); 
			}
			$('ul').on('tap', function(){
				goNewPage('me-bespoke-list-guahao.html', {aid:$(this).attr('aid')});
			})
			
		},
		error :function(e){
			console.log(JSON.stringify(e));
			errortoast();
		}
	});
},false)
